 /**
 * @file tal_end_device.h
 * @brief Common process - end device
 * @version 1.0.0
 * @date 2021-09-09
 *
 * @copyright Copyright 2018-2021 Tuya Inc. All Rights Reserved.
 *
 */
#ifndef __TAL_END_DEVICE_H__
#define __TAL_END_DEVICE_H__


#ifdef __cplusplus
    extern "C" {
#endif

#include "tuya_cloud_types.h"
#include "tuya_zigbee_stack.h"


/*
 * zigbee end-device rejoin type
*/
typedef enum {
    TAL_REJOIN_ON_CURRENT_CH = 0,   ///< rejoin on current channel, duration of single trigger high current is 150ms.
    TAL_REJOIN_ON_ALL_ZG_CH,        ///< rejoin on all 802.25.4 channel(11~26),it will consume more current, duration of single trigger high current is 2.3s.
} TAL_REJOIN_TYPE_E;

/*
 * zigbee end-device rejoin config
*/
typedef struct {
    UINT8_T  power_on_active;       ///< auto rejoin when power on.
    UINT8_T  send_data_active;      ///< auto rejoin when send data if parent lost.
    UINT8_T  reserved;              ///< Reserved
    UINT8_T  attempts;              ///< max rejoin attempts when parent lost.
    UINT16_T interval;              ///< rejoin attempt interval when parent lost.
} TAL_ZG_REJOIN_CFG_T;


/**
 * @brief zigbee end-device rejoin start
 *
 * @param[in]   type: rejoin type
 * @return none
 */
BOOL_T tal_zg_rejoin_start(TAL_REJOIN_TYPE_E type);

/**
 * @brief zigbee end-device abnormal wakeup
 *
 * @param[in]   none
 * @return TRUE: need reset; FALSE: need not reset
 */
BOOL_T tal_abnormal_wakeup_callback(VOID_T);


#ifdef __cplusplus
}
#endif

#endif

